﻿<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:common="clr-namespace:OMANE.Common;assembly=OMANE.Common"
    mc:Ignorable="d"
	x:Class="MessageWindow"	
	Title="MessageWindow" WindowStyle="None" 
    AllowsTransparency="True" 
    Background="{x:Null}" 
    xmlns:my="clr-namespace:OMANE.Common.UI.Theme;assembly=OMANE.Common.UI.Theme" 
	ShowInTaskbar="False" Topmost="True" ResizeMode="CanResizeWithGrip" Style="{DynamicResource WindowStyle1}" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterOwner" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" d:DesignWidth="124" d:DesignHeight="95" MinHeight="125" MinWidth="125">
    <Window.Resources>
        <CornerRadius x:Key="BorderCornerRadius">10</CornerRadius>
        <Thickness x:Key="BorderSize">2</Thickness>
        <SolidColorBrush x:Key="BorderColor" Color="Black"/>
        <GridLength x:Key="ButtonPanelWidth">*</GridLength>
        <GridLength x:Key="ButtonPanelRight">20</GridLength>
        <GridLength x:Key="ButtonPanelHalfHeight">Auto</GridLength>
        <SolidColorBrush x:Key="BorderBackColor" Color="White"/>
        <sys:Double x:Key="ErrorMessageFont">16</sys:Double>
        <FontFamily x:Key="ErrorMessageFontFamily">Calibri</FontFamily>
        <DataTemplate DataType="{x:Type sys:Exception}">
            <Grid Width="600" Height="400" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <TextBlock TextWrapping="Wrap" Text="Source" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="{DynamicResource ErrorMessageFont}" Margin="5"/>
                <TextBlock Grid.Row="1" TextWrapping="Wrap" Text="Message" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="{DynamicResource ErrorMessageFont}" Margin="5"/>
                <TextBlock Grid.Row="2" TextWrapping="Wrap" Text="Trace de la pile" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="{DynamicResource ErrorMessageFont}" Margin="5"/>
                <TextBlock Grid.Column="1" TextWrapping="Wrap" Text="{Binding Source}" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="{DynamicResource ErrorMessageFont}" Margin="5"/>
                <TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Message, Mode=OneWay}" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="{DynamicResource ErrorMessageFont}" Margin="5"/>
                <ScrollViewer Grid.Column="1" Margin="5" Grid.Row="2" CanContentScroll="True" HorizontalScrollBarVisibility="Visible">
                	<TextBlock Text="{Binding StackTrace, Mode=OneWay}" FontFamily="{DynamicResource ErrorMessageFontFamily}" FontSize="12" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="Auto" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Top"/>
                </ScrollViewer>
                <TextBlock Grid.ColumnSpan="2" Grid.Row="3" TextWrapping="Wrap"  VerticalAlignment="Center" HorizontalAlignment="Center">
                	<Hyperlink NavigateUri="www.yahoo.fr" >
                		<Run Text="Envoyer un message à l'administrateur"/>
						</Hyperlink>            
				</TextBlock>
            </Grid>
        </DataTemplate>
        <DataTemplate DataType="{x:Type common:AsynchronousOperationInfo}">
        	<Grid Height="Auto" Width="Auto">
        		<Border Height="30" Width="300" CornerRadius="12" BorderThickness="5" BorderBrush="{DynamicResource DegradeBckTabItem}" Background="{DynamicResource DegradeBckTitre}">
        			<TextBlock TextWrapping="Wrap" Text="{Binding Message}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"/>
        		</Border>
        		<TextBlock Height="Auto" TextWrapping="Wrap" Text="{Binding Path=Progress, StringFormat=\{0:P\}}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,60,0,0" Foreground="#FF161616" FontWeight="Bold" FontSize="13.333"/>
            
        	</Grid>
            
        </DataTemplate>
        <ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}">
            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                <Grid>
                    <AdornerDecorator>
                        <ContentPresenter/>
                    </AdornerDecorator>
                    <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom" Margin="0,0,5,5" />
                </Grid>
            </Border>
            <ControlTemplate.Triggers>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                        <Condition Property="WindowState" Value="Normal"/>
                    </MultiTrigger.Conditions>
                    <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
                </MultiTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <Style x:Key="WindowStyle1" TargetType="{x:Type Window}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Window}">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
                            <AdornerDecorator>
                                <ContentPresenter/>
                            </AdornerDecorator>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="ResizeMode" Value="CanResizeWithGrip">
                    <Setter Property="Template" Value="{StaticResource WindowTemplateKey}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Resources>

    <Grid  DataContext="{Binding}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{DynamicResource ButtonPanelRight}"/>
            <ColumnDefinition Width="{DynamicResource ButtonPanelWidth}"/>
            <ColumnDefinition Width="{DynamicResource ButtonPanelRight}"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="{DynamicResource ButtonPanelHalfHeight}"/>
            <RowDefinition Height="{DynamicResource ButtonPanelHalfHeight}"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Border BorderThickness="{DynamicResource BorderSize}" Grid.Row="1" Grid.RowSpan="2" Grid.ColumnSpan="3" CornerRadius="{DynamicResource BorderCornerRadius}" Background="{DynamicResource BorderBackColor}" BorderBrush="{DynamicResource BrushCouleur1Base}" />
        <Border BorderBrush="{DynamicResource BrushCouleur1Base}" BorderThickness="{DynamicResource BorderSize}" Grid.Column="1" Grid.RowSpan="2" CornerRadius="{DynamicResource BorderCornerRadius}" Background="{DynamicResource DegradeBckTitre}" MouseLeftButtonDown="Border_MouseLeftButtonDown" Cursor="ScrollAll">
            <Grid Margin="5,4,5,4" MouseLeftButtonDown="Grid_MouseLeftButtonDown" Cursor="ScrollAll">
                <Thumb DragDelta="Thumb_DragDelta" Name="windowdragthumb" Cursor="ScrollAll">
                    <Thumb.Template>
                        <ControlTemplate TargetType="Thumb" />
                    </Thumb.Template>
                </Thumb>
                <Grid Cursor="ScrollAll" MouseLeftButtonDown="UniformGrid_MouseLeftButtonDown" >
                	<TextBlock FontWeight="Bold" Foreground="{DynamicResource BrushCouleur1Base}" HorizontalAlignment="Left" d:LayoutOverrides="HorizontalAlignment" VerticalAlignment="Center" Text="OMANE" Name="titleTextBlock" />
                	<Button x:Name="button" Content="X" HorizontalAlignment="Right" VerticalAlignment="Center" BorderBrush="{x:Null}" Padding="0" Click="Button_Click" Cursor="Hand" FontSize="14" FontWeight="Bold" Background="{x:Null}" Foreground="{DynamicResource BrushCouleur1Base}" Width="{Binding ActualHeight, ElementName=button, Mode=OneWay}" FontFamily="Calibri" />
                </Grid>

            </Grid>
        </Border>
        <ContentControl Grid.ColumnSpan="3" Grid.Row="2" Margin="20"
                        DataContext="{Binding}" 
                        Content="{Binding}">
        </ContentControl>
    </Grid>

</Window>